/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [NotepadMenuBar.java]
 * Creation Date        [11-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_02_gui.notepad_V1.ui.main;

import java.io.File;

import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JTextArea;

import pkg_02_gui.notepad_V1.ui.edit.EditMenu;
import pkg_02_gui.notepad_V1.ui.edit.EditMenuListener;
import pkg_02_gui.notepad_V1.ui.file.FileMenu;
import pkg_02_gui.notepad_V1.ui.file.FileMenuListener;
import pkg_02_gui.notepad_V1.ui.format.FormatMenu;
import pkg_02_gui.notepad_V1.ui.format.FormatMenuListener;
import pkg_02_gui.notepad_V1.ui.help.HelpMenu;
import pkg_02_gui.notepad_V1.ui.help.HelpMenuListener;

/**
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class NotepadMenuBar extends JMenuBar {

	private static final long serialVersionUID = 4040142424421319178L;

	private FileMenuListener fileMenu; // 文件菜单
	private EditMenuListener editMenu; // 编辑菜单
	private FormatMenuListener formatMenu; // 格式化菜单
	private HelpMenuListener helpMenu; // 帮助菜单

	private JTextArea textArea = null; // 文本框
	private JLabel statusLabel = null; // 状态栏
	private File file = null; // 文件

	private NotepadFrame frame = null;

	/**
	 * 初始化工具栏
	 */
	private void initMenuBar() {
		setOpaque(false); // 设置透明属性
		setBorderPainted(true); // 设置边框的可见性
	}

	private void initMenu() {
		initMenuBar();
		fileMenu = new FileMenuListener("文件(F)", textArea, statusLabel, file,
				frame);
		editMenu = new EditMenuListener("编辑(E)", textArea, frame);
		formatMenu = new FormatMenuListener("格式(O)", textArea, frame);
		helpMenu = new HelpMenuListener("帮助(H)");

		this.add(fileMenu);
		this.add(editMenu);
		this.add(formatMenu);
		this.add(helpMenu);
	}

	public NotepadMenuBar(NotepadFrame frame, JTextArea textArea,
			JLabel statusLabel, File file) {
		this.frame = frame;
		this.textArea = textArea;
		this.statusLabel = statusLabel;
		this.file = file;
		initMenu();

	}

	public FileMenu getFileMenu() {
		return fileMenu;
	}

	public EditMenu getEditMenu() {
		return editMenu;
	}

	public FormatMenu getFormatMenu() {
		return formatMenu;
	}

	@Override
	public HelpMenu getHelpMenu() {
		return helpMenu;
	}

}
